
# -*- coding: utf-8 -*-

from playwright.sync_api import Playwright, sync_playwright, expect


def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()
    page.goto('http://192.168.7.102/users/sign_in')

    # Interact with login form
    page.get_by_label("Username or email").fill("yangxc@it.lianfa.cn")
    page.get_by_label("Password").fill("victal2422")
    page.get_by_role("button", name="Sign in").click()
    storage = context.storage_state(path="state.json")

    context.close()
    browser.close()


if __name__ == '__main__':
    with sync_playwright() as playwright:
        run(playwright)
